#ifndef __MP_TCP_SERVER_H__
#define __MP_TCP_SERVER_H__

#include "net_base.h"
#include "eventloop.h"
#include "tcp_server_context.h"

namespace Gazella {

class TcpServer: public NetBase {
public:
    TcpServer();
    virtual ~TcpServer();

    //init
    int init(std::string host, int port) override;

protected:
    int m_sd = -1;
    ev::io m_accept_io;

private:
    int __create_tcp_server(std::string host, int port);

    //eventlib
    virtual void __accept_cb(ev::io &w, int revents);

    void __recv_cb(ev::io &w, int revents) override;
    void __send_cb(ev::io &w, int revents) override;
};
}

#endif